/**
* Author: Samfu
* Time  : 下午4:21:00
* Desc  : 
*/
package com.fu.moneybag.utils;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;

public class GetResultMap {
	
	public GetResultMap(){}
	
	private Logger logger = Logger.getLogger(GetResultMap.class);
	
	public HashMap<String, Number> getArticleMap(List<HashMap<String, Integer>> articleGroups) {
		logger.info("artilce分为 " + articleGroups.size());
		// 新建一个hashmap
		HashMap<String, Integer> map = new HashMap<String, Integer>();
		// 新建一个result map 给前段显示
		HashMap<String, Number> resultMap = new HashMap<String, Number>();
		// 遍历list
		for (int i = 0; i < articleGroups.size(); i++) {
			map = articleGroups.get(i);
			Iterator iter = map.entrySet().iterator();
			String resultKey = "";// 类型作为key
			Number resultValue = 0;// 数目作为值
			int j = 0;
			while (iter.hasNext()) {
				Map.Entry entry = (Map.Entry) iter.next();
				Object key = entry.getKey();
				Object val = entry.getValue();
				logger.info("key : " + key);
				logger.info("value : " + val);
				if (j % 2 == 0) {
					resultValue = (Number) val;
				} else {
					resultKey = (String) val;
				}
				j++;
			}
			resultMap.put(resultKey, resultValue);

		}
		return resultMap;
	}


}
